{% extends "profilebase.html" %}

{% block sidebar_title %}
{% if profileOwner %}
	{% if currentUser.category == "student" %}<h4>Questions</h4>{% endif %}
	{% if currentUser.category == "teacher" %}<h4>About Me</h4>{% endif %}
	{% if currentUser.category == "institute" %}<h4>About Us</h4>{% endif %}
{% else %}
	<h4>About {{ currentUser.abstract_user.user.username }}</h4>
{% endif %}
{% endblock %}

{% block sidebar_content %}
{% if profileOwner %}
	{% if currentUser.category == "student" %}
		{% if del_success_message %}
			{{ del_success_message }}<br/><br/>
		{% endif %}
		{% for question in questions %}
			<b>{{ question }}</b> <small><a href="/myprofile/deleteReviewQuestion/{{ question.id }}/">delete</a></small><br/><br/>
		{% empty %}
			You don't have any questions yet
		{% endfor %}
		<hr/>
		<h4>Add a new question</h4><br/>
		{% if add_success_message %}
			{{ add_success_message }}<br/><br/>
		{% endif %}
		<form action="/myprofile/addReviewQuestion/" method="POST">{% csrf_token %}
			<input type="text" name="content"/><br/><br/>
			<input type="submit" id="search_btn" value="Add" />
		</form>
	{% else %}
		{% if currentUser.category == "institute" %}
			<h5>About: </h5><p>{{ currentUser.about|default:"Tell us all about your institute" }}</p>
			<h5>Open On: </h5><p>{{ currentUser.open_on|default:"Ahm, is it closed all the time?" }}</p>
			<h5>Open From: </h5><p>{{ currentUser.open_from|default:"Is it open 24hrs aday?" }}</p>
			<h5>Open To: </h5><p>{{ currentUser.open_to|default:"Never closes?"}}</p>
			<h5>Address: </h5><p>{{ currentUser.address|default:"Even if you're located on Mars, you can tell us, we really don't mind" }}</p>
		{% else %}					
			<h5>Date of Birth: </h5><p>{{ currentUser.dob|default:"Not entered yet" }}</p>
			<h5>Gender: </h5><p>{{ currentUser.gender|default:"Are you unsure?" }}</p>
			<h5>Experience: </h5><p>{{ currentUser.experience|default:"Come on, BRAG!" }}</p>
			<h5>Favourite Genre/s: </h5><p>{{ currentUser.favourite_genre|default:"Hmm, you must like something, right?" }}</p>
			<h5>Instrument/s Played: </h5><p>{{ currentUser.instrument_played|default:"Ahm, it is kind of in the definition of a musician to play something. Unless you're a vocalist...'" }}</p>
			<h5>Jamming Style: </h5><p>{{ currentUser.jamming_style|default:"Tell us..." }}</p>
			<h5>Teach: </h5><p>{{ currentUser.teaches|default:"Advertise for yourself..." }}</p>
		{% endif %}
		<a href="/editInfo/">Edit My Info</a> - 
		{% if photoPath %}	
			<a href="/myprofile/uploadImage/">Change Photo</a>
		{% else %}
			<a href="/myprofile/uploadImage/">Upload a Photo</a>
		{% endif %}
	{% endif %}
{% else %}
	{% if currentUser.category == "institute" %}
		{% if currentUser.about %}
			<h5>About: </h5><p>{{ currentUser.about }}</p>
		{% endif %}
		{% if currentUser.open_on %} 
			<h5>Open On: </h5><p>{{ currentUser.open_on }}</p> 
		{% endif %}
		{% if currentUser.open_from %} 
			<h5>Open From: </h5><p>{{ currentUser.open_from }}</p> 
		{% endif %}
		{% if currentUser.open_to %} 
			<h5>Open To: </h5><p>{{ currentUser.open_to }}</p> 
		{% endif %}
		{% if currentUser.address %} 
			<h5>Address: </h5><p>{{ currentUser.address }}</p> 
		{% endif %}
		
	{% else %}
	
		{% if currentUser.dob %} 
			<h5>Date of Birth: </h5><p>{{ currentUser.dob }}</p> 
		{% endif %}
		{% if currentUser.gender %} 
			<h5>Gender: </h5><p>{{ currentUser.gender }}</p> 
		{% endif %}
		{% if currentUser.experience %} 
			<h5>Experience: </h5><p>{{ currentUser.experience }}</p> 
		{% endif %}
		{% if currentUser.favourite_genre %} 
			<h5>Favourite Genre/s: </h5><p>{{ currentUser.favourite_genre }}</p> 
		{% endif %}
		{% if currentUser.instrument_played %} 
			<h5>Instrument/s Played: </h5><p>{{ currentUser.instrument_played }}</p> 
		{% endif %}
		{% if currentUser.jamming_style %} 
			<h5>Jamming Style: </h5><p>{{ currentUser.jamming_style }}</p> 
		{% endif %}
		
		{% if currentUser.category == "teacher" %}
			{% if currentUser.teaches %}
				<h5>Teach: </h5><p>{{ currentUser.teaches }}</p>
			{% endif %}
		{% endif %}
			
	{% endif %}
	
{% endif %}
{% endblock %}

{% block main_title %}<h1>Reviews</h1>{% endblock %}

{% block main_subtitle %}
{% if reviews %}
	<small>What everyone thinks of {{ currentUser.abstract_user.user.username }}</small>
{% else %}
	<small>{{ currentUser.abstract_user }} doesn't have any reviews yet</small>
{% endif %}
{% endblock %}

{% block main_content %}
{% if not profileOwner and areFriends %}
	{% if media %}
		<form action="/myprofile/postMediaReview/{{ currentUser.abstract_user.id }}/{{ media.id }}/" method="POST">{% csrf_token %}
		{% if review_success_message %}
			{{ review_success_message }}<br/><br/>
		{% endif %}
		
		{%  if media.video_id %}
			<iframe width="560" height="315" src="http://www.youtube.com/embed/{{ media.video_id }}" frameborder="0" allowfullscreen></iframe>
			<br/>
		{% else %}
			<object height="100" width="100%"> 
			<param name="movie" value={{ media.mp3_url }}/> 
		</object> 
		<br/>
		{% endif %}
		
		<textarea name="content" size=80 style="height:100px;"></textarea><br/>
		
		<input type="submit" id="search_btn" value="Post"><br /><br /><br />
		</form>
	{% else %}
		<form action="/myprofile/postReview/{{ currentUser.abstract_user.id }}/" method="POST">{% csrf_token %}
		{% if review_success_message %}
			{{ review_success_message }}<br/><br/>
		{% endif %}
		
		{% if currentUser.category == "student" %}
			{% for question in questions %}
				<b>{{ question }}</b><br/>
				<input type="text"  name="question_{{ question.id }}"/>
				<br/><br/>
			{% endfor %}
		{% endif %}
		{% if currentUser.category == "student" %}
			<b>Other Comments:</b>
		{% endif %}
	
		<textarea name="content" size=80 style="height:100px;"></textarea><br/>
		
		{% if currentUser.category == "student" %}
			<input type="radio" name="category" value="public" checked="checked" /> Public
			<input type="radio" name="category" value="private" /> Private <br/><br/>
		{% endif %}
		
		<input type="submit" id="search_btn" value="Post"><br /><br /><br />
		</form>
	{% endif %}
{% endif %}

{% for review in reviews %}
	<li>
		<small>
			<a href="/myprofile/{{ review.reviewer.id }}/">{{ review.reviewer }}</a> on {{ review.date }} 
			{% if review.report_count > 0 %}
				<small>Reported, <a href="/myprofile/report/{{ review.id }}/{{ currentUser.abstract_user.id }}/">Report again</a></small><br/> 
			{% else %}
				<small><a href="/myprofile/report/{{ review.id }}/{{ currentUser.abstract_user.id }}/">Report</a></small><br/>
			{% endif %}

			<p>{{ review.content|safe }}</p>	
		
			{% if review.media %}
				{%  if review.media.video_id %}
					<iframe width="200" height="100" src="http://www.youtube.com/embed/{{ review.media.video_id }}" frameborder="0" allowfullscreen></iframe>
					<br/>
				{% else %}
					<object height="100" width="100%"> 
						<param name="movie" value={{ review.media.mp3_url }}/> 
					</object> 
					<br/>
				{% endif %}
			{% endif %}
		</small>
	{# the following spaces are merely used such that the reviews don't get positioned next to each other #}
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	</li>
{% endfor %}
{% if more_reviews_available %}
<br/>
<li><small><a href="/myprofile/viewMoreReviews/{{ currentUser.abstract_user.id }}/{{ reviews|length }}">view more reviews</a></small></li>
{% endif %}
{% endblock %}
